home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 May: Tool Chest / Dev.CD May 98 TC.toast / Tool Chest / Localization / Verifier 1.0 / v.Verify < prev    next >
Encoding:
Text File  |  1994-02-09  |  13.1 KB  |  470 lines  |  [TEXT/MPS ]

  1. #
  2. #    v.Verify
  3. #
  4. #    12/11/92
  5. #    Kerry Laidlaw
  6. #    Apple Computer, Inc.
  7. #
  8. #    Function:
  9. #    Compare two disks or folders, file by file, all the resources and data
  10. #    forks.  Also compare the file attributes too.  Generate a report showing
  11. #    the differences between the two disks or folders.  The report lists the
  12. #    differences file by file.
  13. #
  14. #
  15.  
  16. #    Save some initial shell variable values, and set them for our own use
  17.  
  18.     set saveExit    {exit}
  19.     set exit    0        # Set exit 0 so we won't abort if status variable is non-zero
  20.     set saveEcho {echo}    # echo=1 for echoing each command before execution
  21.     set echo 0
  22.     set saveDir `directory`
  23.     
  24.     set UseFileList        "off"
  25.     
  26.     for theParameter in {"Parameters"}
  27.         if "{theParameter}" == "-name"
  28.             shift 1
  29.             set UserName        "{1}"
  30.         else if "{theParameter}" == "-productname"
  31.             shift 1
  32.             set ProductName        "{1}"
  33.         else if "{theParameter}" == "-reportfolder"
  34.             shift 1
  35.             set ReportFolder    "{1}"
  36.             if `evaluate "{ReportFolder}" =~ /:(≈)®1/`
  37.                     set ReportFolder "{®1}"
  38.                     set ReportFolder "`directory -q`""{ReportFolder}"
  39.             end
  40.         else if "{theParameter}" == "-master"
  41.             shift 1
  42.             set MasterFolder    "{1}"
  43.             if `evaluate "{MasterFolder}" =~ /:(≈)®1/`
  44.                     set MasterFolder "{®1}"
  45.                     set MasterFolder "`directory -q`""{MasterFolder}"
  46.             end
  47.         else if "{theParameter}" == "-test"
  48.             shift 1
  49.             set TestFolder        "{1}"
  50.             if `evaluate "{TestFolder}" =~ /:(≈)®1/`
  51.                     set TestFolder "{®1}"
  52.                     set TestFolder "`directory -q`""{TestFolder}"
  53.             end
  54.         else if "{theParameter}" == "-filelist"
  55.             shift 1
  56.             set FileList        "{1}"
  57.             if `evaluate "{FileList}" =~ /:(≈)®1/`
  58.                     set FileList "{®1}"
  59.                     set FileList "`directory -q`""{FileList}"
  60.             end
  61.         else if "{theParameter}" == "-rnames"
  62.             shift 1
  63.             set rNamesFolder    "{1}"
  64.             if `evaluate "{rNamesFolder}" =~ /:(≈)®1/`
  65.                     set rNamesFolder "{®1}"
  66.                     set rNamesFolder "`directory -q`""{rNamesFolder}"
  67.             end
  68.         else if "{theParameter}" == "-usefilelist"
  69.             shift 1
  70.             set UseFileList        "on"
  71.         else if "{theParameter}" == "-countryCode"        
  72.             shift 1    
  73.             set countryCodeDefault "{1}"                    #    remember the pop-up for next time
  74.             export countryCodeDefault
  75.             (evaluate "{1}" =~ /?(??)®1≈/) >dev:null
  76.             (evaluate "{1}" =~ /????(??)®2≈/) >dev:null
  77.             set LangInt     "{®1}"
  78.             if     `evaluate "{LangInt}" =~ / (≈)®1/`
  79.                 set LangInt     "{®1}"
  80.             end
  81.             set LangCode     "{®2}"
  82.             if     `evaluate "{LangCode}" =~ /(?)®2 ≈/`
  83.                 set LangCode     "{®2}"
  84.             end
  85.         else
  86.             shift 1
  87.         end
  88.     end
  89.     
  90.     if `exists -d "{ReportFolder}"`
  91.         set ReportFile    "{ReportFolder}""{ProductName}".rpt
  92.         if "{UseFileList}" == "off"
  93.             set FileList    "{ReportFolder}""{ProductName}".lst
  94.         end
  95.     else
  96.         set ReportFile    "`directory -q`""{ProductName}".rpt
  97.         if "{UseFileList}" == "off"
  98.             set FileList "`directory -q`""{ProductName}".lst
  99.         end
  100.     end
  101.     
  102. # Let the other scripts use the input parameters
  103.  
  104.     Export UserName
  105.     Export ProductName
  106.     Export ReportFile
  107.     Export MasterFolder
  108.     Export TestFolder
  109.     Export FileList
  110.     Export rNamesFolder
  111.     Export LangCode
  112.     Export LangInt
  113.  
  114. #echo filelist- "{FileList}"
  115. #echo rnames- "{rNamesFolder}"
  116. #echo username- "{UserName}"
  117. #echo productname- "{ProductName}"
  118. #echo reportfile- "{ReportFile}"
  119.     
  120. #    Now update user defaults file with any new values user entered
  121.     set            DefaultStringsFile "{mpw}"scripts:V.DefaultStrings
  122.     target    "{DefaultStringsFile}"
  123.     
  124.     find     1
  125.     if     ("`catenate §`" == "•No Default•")
  126.         replace    1    "{UserName}"∂n    
  127.     end
  128.     find     2
  129.     if     ("`catenate §`" == "•No Default•")
  130.         replace    2    "{ProductName}"∂n
  131.     end
  132.     find     3
  133.     if     ("`catenate §`" == "•No Default•")
  134.         replace    3    "{rNamesFolder}"∂n
  135.     end
  136.     find     4
  137.     if     ("`catenate §`" == "•No Default•")
  138.         replace    4    "{MasterFolder}"∂n
  139.     end
  140.     find     5
  141.     if     ("`catenate §`" == "•No Default•")
  142.         replace    5    "{TestFolder}"∂n
  143.     end
  144.     find     6
  145.     if     ("`catenate §`" == "•No Default•")
  146.         replace    6    "{ReportFolder}"∂n
  147.     end
  148.     find     7
  149.     if     ("`catenate §`" == "  1/F  - France")
  150.         replace    7    "{countryCodeDefault}"∂n
  151.     end
  152.     find     8
  153.     if     ("`catenate §`" == "•No Default•")
  154.         replace    8    "{FileList}"∂n
  155.     end
  156.  
  157.     
  158.     close -y        # Save the changes to the default file
  159.  
  160.     if    (                                                            ∂
  161.                     ("{UseFileList}" == "off")                        ∂
  162.                 &&                                                    ∂
  163.                     (                                                ∂
  164.                         ("{MasterFolder}" == "•No Default•")    ||     ∂
  165.                         ("{TestFolder}" == "•No Default•")        ||     ∂
  166.                         ("{ReportFolder}" == "•No Default•")    ||     ∂
  167.                         ("{rNamesFolder}" == "•No Default•")        ∂
  168.                     )                                                ∂
  169.         )                                                            ∂
  170.     ||                                                                 ∂
  171.         (                                                            ∂
  172.                     ("{UseFileList}" == "on")                        ∂
  173.                 &&                                                     ∂
  174.                     (                                                ∂
  175.                         ("{FileList}" == "•No Default•")        ||     ∂
  176.                         ("{ReportFolder}" == "•No Default•")    ||     ∂
  177.                         ("{rNamesFolder}" == "•No Default•")        ∂
  178.                     )                                                ∂
  179.         )
  180.         alert    "You must supply a parameter where ever you see:∂n∂n∂t∂t∂t∂t∂t∂t∂t∂t∂t∂t∂t∂t∂t∂"•No Default•∂"∂n∂n∂
  181. Please select the ∂"Create Report...∂" menu item again."
  182.  
  183.         exit 2
  184.     end
  185.     
  186.     if    "{ProductName}"  !~ /?«1,23»/
  187.         alert    "The Product Name must be 23 characters or less.∂n∂n∂
  188. Please select the ∂"Create Report...∂" menu item again and edit the Product Name."
  189.         exit 2
  190.     end    
  191.     
  192. #    Now lets make sure all files are decompressed (Type = 'splt',Creator = 'csw2')
  193.  
  194. set tempDir `directory`
  195.  
  196. directory    "{MasterFolder}"        # Decompress all files in the Master Folder
  197. For aFile in `Files -f -r`
  198.     if `exists -f "{aFile}"`
  199.         decompressIt    "{aFile}"
  200.     end
  201. end
  202.  
  203. directory    "{TestFolder}"            # Decompress all files in the Test Folder
  204. For aFile in `Files -f -r`
  205.     if `exists -f "{aFile}"`
  206.         decompressIt    "{aFile}"
  207.     end
  208. end
  209.  
  210. directory    "{tempDir}"            # Leave the directory setting unchanged
  211.  
  212. if "{UseFileList}" == "off"
  213.     set    i    1
  214.     loop
  215.         new "{FileList}"    ≥    dev:null    # ignore errors, since we handle them ourself
  216.         set    saveStatus    {status}
  217.         if {saveStatus} == 0        #    Successfully created
  218.             break
  219.         else if {saveStatus} == 2    #    File already exists, append a numeric suffix
  220.             if `evaluate "{FileList}" =~ /(≈)®1[.][0-9]+/`
  221.                 set  FileList    "{®1}"."{i}"
  222.             else
  223.                 set FileList    "{FileList}"."{i}"
  224.             end
  225.             set i `evaluate {i} + 1`
  226.         else
  227.             echo "Creation of the File List ∂"{filelist}∂" failed."    >>    "{ReportFile}"
  228.             echo "Creation of the File List ∂"{filelist}∂" failed."    >>    "{WorkSheet}"
  229.             exit                    # Can't continue.
  230.         end
  231.     end    
  232.     
  233. #    Now go create the filelist
  234.  
  235.     v.filelist ≥≥ "{Worksheet}"    # Send any diagnostic error messages to the users worksheet
  236.     
  237. else    # make sure the filelist file exists
  238.     if !`exists "{FileList}"`
  239.         alert "Your selected file list is missing: ∂n∂n∂"{FileList}∂"∂n∂nSelect another, or uncheck the File List option."
  240.         set echo    {saveEcho}             # restore echo
  241.         set exit    "{saveExit}"
  242.         exit 2
  243.     end
  244. end
  245.  
  246. #    A new report file is always created.  If the file already exists, then add a numeric suffix.
  247. set    i    1
  248. loop
  249.     new "{ReportFile}"    ≥    dev:null    # ignore errors, since we handle them ourself
  250.     set    saveStatus    {status}
  251.     if {saveStatus} == 0        #    Successfully created
  252.         break
  253.     else if {saveStatus} == 2    #    File already exists, append a numeric suffix
  254.         if `evaluate "{ReportFile}" =~ /(≈)®1[.][0-9]+/`
  255.             set  ReportFile    "{®1}"."{i}"
  256.         else
  257.             set ReportFile    "{ReportFile}"."{i}"
  258.         end
  259.         set i `evaluate {i} + 1`
  260.     else
  261.         echo "Creation of the Report File ∂"{ReportFile}∂" failed."    >>    "{ReportFile}"
  262.         echo "Creation of the Report File ∂"{ReportFile}∂" failed."    >>    "{WorkSheet}"
  263.         exit                    # Can't continue.
  264.     end
  265. end
  266.  
  267. open    "{FileList}"    
  268. set    saveStatus    {status}
  269. if {saveStatus} != 0        #    Successfully created
  270.     alert "Could not open File List file: ∂"{FileList}∂".  Please generate a new File List, ∂
  271. and create the report again."
  272.     set echo    {saveEcho}             # restore echo
  273.     set exit    "{saveExit}"
  274.     exit 2
  275. end
  276.  
  277. open    "{ReportFile}"    
  278. if {saveStatus} != 0        #    Successfully created
  279.     echo "Could not open Report file: ∂"{ReportFile}∂""    >>    "{ReportFile}"
  280.     echo "Could not open Report file: ∂"{ReportFile}∂""    >>    "{WorkSheet}"
  281.     alert "Could not open Report file: ∂"{ReportFile}∂".  Select a new directory for the report, ∂
  282. and create the report again."
  283.     set echo    {saveEcho}             # restore echo
  284.     set exit    "{saveExit}"
  285.     exit 2
  286. end
  287.  
  288. TileWindows
  289.  
  290. # First off, lets verify the filelist file contents are ok.
  291.  
  292. find • "{filelist}"    #    Move to the beginning of the file list window
  293. set nLines `count -l "{filelist}"`        # Get the number of lines in the filelist file
  294. # if file is not empty, and has an even number of lines then we are Ok
  295. if (`evaluate "{nLines}"` >= 2) && !(`evaluate "{nLines}"` & 1)    
  296.     set NumberOfLinesOk TRUE
  297. else
  298.     set NumberOfLinesOk FALSE
  299. end
  300.  
  301. #    Get the filenames from the file list file and make sure they exist
  302.  
  303. set FileMissing        FALSE
  304. loop
  305.     find /•≈∞/ "{filelist}"        # Get a line from filelist.
  306.     break if `count -l "{filelist}.§"` == 0        # Exit loop if end.
  307.     set aFile "`catenate "{filelist}.§"`"
  308.     if !`exists "{aFile}"`
  309.         set FileMissing        TRUE
  310.         break
  311.     end
  312. end
  313.  
  314. if (NumberOfLinesOk == FALSE) || (FileMissing == TRUE)
  315.     alert "Cannot find files described in File List.  Please generate a new File List, ∂
  316. and restart the command from the menu."
  317.     set echo    {saveEcho}             # restore echo
  318.     set exit    "{saveExit}"
  319.     exit 2
  320. end
  321.  
  322. #    Create the header of the report:
  323.  
  324. (
  325.     echo "Using Verifier Version" "{VerifierVersion}"
  326.     echo "============================================================================"
  327.     echo "Product:      {ProductName}"                
  328.     echo "Report Date:  `date`" 
  329.     echo "From:         {UserName}"   
  330.     echo 
  331.     echo "Verified by:"    
  332.     echo
  333. ) > "{ReportFile}"        # Clear previous data (if any) and write out the header
  334.  
  335.  
  336. #    Now list the files that will be verified in the report header:
  337.  
  338.     echo "Files Verified:"  >> "{ReportFile}"
  339.  
  340. #    Now let's list the filenames in the header of the report
  341. #    Loop on the filenames from the filelist.
  342.         
  343. Find • "{filelist}"    #    Move to the beginning of the file list window
  344.  
  345. set loopEnd `evaluate {nLines} DIV 2`
  346. set loopIndex 1
  347.  
  348. loop
  349.  
  350. # Get the US names from the filelist and list them for reference
  351.     find /•≈∞/ "{filelist}"        # Get a line from filelist.
  352.     
  353.     set USfile "`catenate "{filelist}.§"`"
  354.     
  355. #    Now we have the full pathname of the file, let's strip off the path info
  356. #    and output just the filename to the Verifier report header
  357.     (evaluate "{USfile}" =~ /([¬:]+:)*(≈)®1/) > dev:null
  358.     set USfilename "{®1}"            
  359.  
  360.     echo -n "{USfilename}"
  361.     versShow "{USfile}"
  362.  
  363.     # Skip the localized name from the filelist.
  364.     find /•≈∞/ "{filelist}"        # Get the next line from filelist.
  365.     
  366.     if {loopIndex} % 4 == 0        # Display 4 file names per line
  367.         echo ", "    
  368.     else if {loopIndex} != {loopEnd}
  369.         echo -n ", "            # Add a comma after each filename
  370.     end
  371.     break if {loopIndex} == {loopEnd}        # Exit loop if end
  372.     set loopIndex `Evaluate {loopIndex} + 1`    # Increment my loop counter
  373.     
  374. end    >> "{ReportFile}"    # End of loop on the files in the correspondence filelist.
  375.  
  376. (
  377.     echo
  378.     echo
  379.     echo "The items marked with ••• need be corrected or justified before GM release."
  380.     echo "Additional comments, indicated with '==>' are for your information only."
  381.     echo
  382. ) >> "{ReportFile}"
  383.  
  384. #    End of header
  385.     
  386. (
  387.     echo "     Using filelist:" "{filelist}" 
  388.     echo "Using rNames folder:" "{rNamesFolder}"
  389.     echo "============================================================================"
  390.     echo
  391. ) >> "{ReportFile}"
  392.  
  393. #     Compare the files.
  394.  
  395. find • "{filelist}"    #    Move to the beginning of the file list window
  396.  
  397. #    Loop on the filenames from the filelist.
  398. loop
  399.  
  400. #    Get the filenames in the loop variables USfile and localfile.
  401.     # Get the US name from the filelist.
  402.     find /•≈∞/ "{filelist}"        # Get a line from filelist.
  403.     break if `count -l "{filelist}.§"` == 0        # Exit loop if end.
  404.     set USfile "`catenate "{filelist}.§"`"
  405.     
  406.     # Get the test name from the filelist.
  407.     find /•≈∞/ "{filelist}"        # Get the next line from filelist.
  408.     set Localfile "`catenate "{filelist}.§"`"
  409.     
  410. #    SCM begin
  411.     
  412. #    Tell the user what file is being compared, and check the 'vers' resources
  413. #    for proper format and data:
  414.     (
  415.         echo "============================================================================"
  416.         echo "  Master file: ∂"{USfile}∂""
  417.         echo "     CheckSum: `CheckSumTool "{USfile}"`"
  418.         echo
  419.         echo "    Test file: ∂"{Localfile}∂""
  420.         echo "     CheckSum: `CheckSumTool "{Localfile}"`"
  421.         echo "----------------------------------------------------------------------------"
  422.         echo "Checking ∂'vers∂' resources in ∂"{Localfile}∂""
  423.         IntlVersCheck "{LangCode}" "{LangInt}" "{USfile}" "{Localfile}"
  424.         echo "============================================================================"
  425.     )  >> "{ReportFile}"
  426.     
  427. #    SCM end
  428.  
  429.  
  430. #echo "{USfile}"  "{Localfile}"    "{rNamesFolder}"    "{ReportFile}"
  431.  
  432.     resdiff        "{USfile}"  "{Localfile}"    "{rNamesFolder}"    "{ReportFile}"    # Compare the resources. 9/1
  433.     equal -d    "{USfile}"    "{Localfile}" >> "{ReportFile}"                # Compare the data fork.
  434.     
  435. #     Add blank line to the output in between files.
  436.     echo     >> "{ReportFile}"                
  437.  
  438. end    # End of loop on the files in the correspondence filelist.
  439.  
  440. close -y "{filelist}"
  441.  
  442. (
  443.     echo
  444.     echo "============================================================================"
  445.     echo "                  End Report - `date`"
  446.     echo "============================================================================"
  447.     echo
  448. ) >> "{ReportFile}"
  449.  
  450. #    Now go to the top of the report window
  451.  
  452. find •    "{ReportFile}"
  453. ZoomWindow    "{ReportFile}"
  454. save    "{ReportFile}"
  455. open    "{ReportFile}"
  456.  
  457. #    beep 1e,4; beep 1c,5            # Make a pleasant tone to say I'm done.
  458.  
  459.     Alert "The following Verifier Report was created:∂n∂n∂t" "{ReportFile}"
  460.  
  461.     
  462. #    Restore shell variables and exit
  463.  
  464.     directory    "{saveDir}"            # Leave the directory setting unchanged
  465.     set echo    {saveEcho}             # restore echo
  466.     set exit    "{saveExit}"
  467.     
  468.  
  469.  
  470.